package tr.edu.metu.is.mega.server.timer;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import tr.edu.metu.is.mega.server.business.MailService;
import tr.edu.metu.is.mega.server.dao.AnnouncementDAO;
import tr.edu.metu.is.mega.server.entity.Announcement;

/**
 * Announcements notify helper for announcements in a course, notifies
 * announcements entered in last hour.
 */
public class AnnouncementNotifier {

    public static void doJob() {
        System.out.println("AnnouncementNotifier.doJob() " + new Date());
        AnnouncementDAO dao = new AnnouncementDAO();
        List<Announcement> findByNamedNativeQuery = dao.findByNamedNativeQuery("Announcement.getAnnouncementsToMail", new HashMap<Integer, Object>());
        for (Announcement activity : findByNamedNativeQuery) {
            MailService.announcementMailer(activity);
        }
    }

}
